package com.theinit.ecommerce.service;

import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.map.annotate.JsonRootName;
import com.theinit.ecommerce.factory.RestTemplateFactory;
import com.theinit.ecommerce.model.*;

public class ProductService {
	
	private final static String productServiceEndpoint = "http://commerce-ville.appspot.com/api/products";
	
	public static Product getProduct(int id, String lang) {	
		return RestTemplateFactory.getTemplate().getForObject(productServiceEndpoint + "/" + id + ".json", Product.class);
	}
	
	public static List<Product> getProducts(int page, String lang) {
		Products products = RestTemplateFactory.getTemplate().getForObject(productServiceEndpoint + ".json",Products.class);
		return products;
	}
	
	@JsonRootName(value = "products")
	public static class Products extends ArrayList<Product> {
	
	}

}
